import BackendLayout from '@/layouts/backend-layout'

import module01 from './modules/module01'
// 英雄模块的路由对象
import champion from './modules/champion'

const meta = { auth: false }
const name = 'admin'

export default [
    {
        path: '/admin',
        name,
        redirect: { name: `${name}-dashboard` },
        meta,
        component: BackendLayout,
        children: [
            {
                path: 'dashboard',
                name: `${name}-dashboard`,
                meta: {
                    title: '主控台',
                    closable: false
                },
                component: () => import('@/pages/admin/dashboard')
            },
            {
                path: 'log',
                name: `${name}-log`,
                meta: {
                    title: '前端日志'
                },
                component: () => import('@/pages/admin/log')
            },
            // 刷新页面 必须保留
            {
                path: 'refresh',
                name: 'refresh',
                hidden: true,
                component: {
                    beforeRouteEnter (to, from, next) {
                        next(instance => instance.$router.replace(from.fullPath));
                    },
                    render: h => h()
                }
            },
            // 页面重定向 必须保留
            {
                path: 'redirect/:route*',
                name: 'redirect',
                hidden: true,
                component: {
                    beforeRouteEnter (to, from, next) {
                        next(instance => instance.$router.replace(JSON.parse(from.params.route)));
                    },
                    render: h => h()
                }
            }
        ]
    },
    module01,
    champion
]
